﻿using Dapper;
using Summer.IService;
using Summer.IService.core;
using Summer.Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace Summer.Service.custom
{
    public class UserService : BaseService<Users,Int32>, IUserService
    {
        private IDbFactory _dbFactory;
        public UserService(IDbFactory dbFactory):base(dbFactory)
        {
            _dbFactory = dbFactory;
        }

        public List<Users> GetUsers()
        {
            using (var cnn = _dbFactory.Create())
            {
                return cnn.Query<Users>("select * from Users where isdeleted=0").AsList();
            }
        }

        public Users GetUser(int userId)
        {
            using (var cnn=_dbFactory.Create())
            {
                return cnn.QuerySingle<Users>("select * from Users where userid=@userId" ,new { userId});
            }
        }
    }
}
